﻿using Md.Api.Model;
using Md.Api.Model.Web.MdUserExperiencer.Request;
using Md.Api.Service.Web.MdUserExperiencer;
using Microsoft.AspNetCore.Mvc;

namespace Md.Api.Controllers.Web;
/// <summary>
/// PC体验师管理
/// </summary>
[ApiController]
[Produces("application/json")]
[Route("md-api/web/userExperiencer")]
public class MdUserExperiencerWebController : ControllerBase
{
    /// <summary>
    /// 通过用户编号检查用户是否申请过体验师服务
    /// </summary>
    public CheckMdUserExperiencerByUserIdWebService checkMdUserExperiencerByUserIdWebService { get; set; }
    /// <summary>
    /// 通过用户编号检查用户是否申请过体验师
    /// </summary>
    /// <param name="userId">用户编号</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpGet("check/apply/{userId}")]
    public async Task<ResponseMessageModel> CheckMdUserExperiencerByUserIdWeb(long userId, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestCheckMdUserExperiencerByUserIdWebModel();

        model.UserId = userId;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => checkMdUserExperiencerByUserIdWebService.Execute(model));
    }

    /// <summary>
    /// 添加体验师服务
    /// </summary>
    public InsertMdUserExperiencerWebService insertMdUserExperiencerWebService { get; set; }
    /// <summary>
    /// 添加体验师
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPost]
    public async Task<ResponseMessageModel> InsertMdUserExperiencerWeb([FromBody] RequestInsertMdUserExperiencerWebModel model)
    {
        return await Task.Run(() => insertMdUserExperiencerWebService.Execute(model));
    }

    /// <summary>
    /// 通过编号获取体验师详情服务
    /// </summary>
    public GetMdUserExperiencerByIdWebService getMdUserExperiencerByIdWebService { get; set; }
    /// <summary>
    /// 通过编号获取体验师详情
    /// </summary>
    /// <param name="userExperiencerId">体验师编号</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpGet("{userExperiencerId}")]
    public async Task<ResponseMessageModel> GetMdUserExperiencerByIdWeb(long userExperiencerId, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestGetMdUserExperiencerByIdWebModel();

        model.UserExperiencerId = userExperiencerId;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => getMdUserExperiencerByIdWebService.Execute(model));
    }

    /// <summary>
    /// 分页获取体验师列表服务
    /// </summary>
    public GetMdUserExperiencerPageListWebService getMdUserExperiencerPageListWebService { get; set; }
    /// <summary>
    /// 分页获取体验师列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("listPage"), HttpPost]
    public async Task<ResponseMessageModel> GetMdUserExperiencerPageListWeb([FromBody] RequestGetMdUserExperiencerPageListWebModel model)
    {
        return await Task.Run(() => getMdUserExperiencerPageListWebService.Execute(model));
    }
}

